﻿using System;
using System.Windows;
using System.Windows.Forms;

namespace PluginMediatorSample.Classes
{
    /// <summary>
    /// Simple ViewModel that registers to a message from the Mediator
    /// This ViewModel demos the Non-Attribute based registration 
    /// </summary>
	class C : BaseViewModel
	{
        public C()
		{
            Mediator.Register<Test2Delegate>(this, "message", Test);
            MessageBox.Show(string.Format("+ {0}", typeof(C).Name));
        }
       
        private void Test(SomeData2 data)
        {
            MessageBox.Show(string.Format("{0} : {1}", typeof(C).Name, data.Value));
        }

        /// <summary>
        /// Finalizer to show that the ViewModel is garbage collected
        /// </summary>
        ~C()
        {
            Mediator.Unregister<Test2Delegate>(this, "message", Test);
            MessageBox.Show(string.Format("- {0}", typeof(C).Name));
        }
    }
}